<!--
 * @Author: thats-all-right-ha-ha 8280209+thats-all-right-ha-ha@user.noreply.gitee.com
 * @Date: 2024-03-02 20:35:07
 * @LastEditors: thats-all-right-ha-ha 8280209+thats-all-right-ha-ha@user.noreply.gitee.com
 * @LastEditTime: 2024-03-03 19:36:27
 * @FilePath: \hrManage\src\views\employee\components\EmployeeTree.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <el-cascader size="mini" :options="list" :props="props" :value="value" @change="subId" />
</template>
<script>
import { getDepartment } from '@/api/department'
import { getDepartmentTree } from '@/utils/index'
export default {
  props: {
    value: {
      type: Number
    }
  },
  data() {
    return {
      list: [],
      props: {
        value: 'id',
        label: 'name'
      }
    }
  },
  created() {
    this.getDepartment()
  },
  methods: {
    async getDepartment() {
      this.list = getDepartmentTree(await getDepartment(), 0)
      console.log(await getDepartment())
    },
    subId(e) {
      if (e.length > 0) {
        this.$emit('input', e[e.length - 1])
      } else {
        this.$emit('input', null)
      }
    }
  }
}
</script>

<style>

</style>
